<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=0" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no" />
    <meta name="format-detection" content="email=no" />
    <link rel="stylesheet" href="{$Think.config.RESOURCEURL}wx_assets/css/common.css{$Think.config.RESOURCE_VER}" onerror="_cdnFallback(this)">
    <link type="text/css" rel="stylesheet" href="{$Think.config.RESOURCEURL}wx_assets/css/zepto.alert.css" />
    <link type="text/css" rel="stylesheet" href="{$Think.config.RESOURCEURL}wx_assets/css/wish/index.css" />

    <script type='text/javascript' src='{$Think.config.RESOURCEURL}wx_assets/js/zepto.1.1.3.min.js'></script>

    <script type='text/javascript' src='{$Think.config.RESOURCEURL}wx_assets/js/json2.js'></script>

    <script src="{$Think.config.RESOURCEURL}wx_assets/js/zepto.alert.js" type="text/javascript"></script>

    <script src="{$Think.config.RESOURCEURL}wx_assets/js/util.js" type="text/javascript"></script>

</head>
<body>
        <if condition="$buyWishText eq ''">
        <div class="pay1">
            <div class="top-info">
                支付已成功<br />
                <span>已经帮助好友达成了心愿，给TA留下你的祝福吧...</span>
            </div>
            <div class="zhufu-box">
                <textarea placeholder="给TA留下祝福吧..." id="wishText"></textarea>
            </div>
            <a class="btn-red" id="BtnOk">确定</a>
        </div>
        <else/>
        <div class="pay2">
            <div class="top-info">
                {$buyWishText}
            </div>
             <a class="btn-red" href='{$Think.config.SERVER_HOST}call.html?customerId={$customerId}&userName={$userName}&module=wish&method=createWish&params=%7B"actId"%3A"{$actId}"%7D'>创建我的心愿单</a>
        </div>
        </if>
        <script type="text/javascript">
            var baseUrl = '{$Think.config.SERVER_HOST}';
            var wish = {
                init: function() {
                    this._initEvent();
                },
                _save: function() {
                    var customerId = $.util.getParam("customerId");
                    var userName = $.util.getParam("userName");
                    var postUrl = baseUrl + 'call.json?customerId={$customerId}';
                    var data = {
                        oid:"{$oid}",
                        id:'{$wishId}',
                        wishText:$("#wishText").val()
                    };
                    $.ajax({
                        url: postUrl,
                        dataType: "json",
                        type: "POST",
                        data: {
                            module: 'wish',
                            method: 'saveBuyWish',
                            userName:'{$userName}',
                            params: JSON.stringify(data)
                        },
                        success: function(data) {
                            var orderId="{$oid}";
                            var wishId="{$wishId}";
                            var actId="{$actId}";
                            if(!data.code) {
                                location.href = baseUrl + 'call.html?customerId={$customerId}&module=wish&method=index&params={"actId":"'+actId+'"}';
                            }
                        }
                    });
                },
                _initEvent: function() {
                    var me = this;
                    $("#BtnOk").click(function() {
                        me._save();
                    });
                }
            }
            wish.init();
        </script>
</body>
</html>
